package org.gruposp2p.dnie.client.ui.panel;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Widget;

public class TopPanel extends Composite {
	
    public static String HISTORY_UPLOAD_DOCUMENT = "#uploadDocument";
    public static String HISTORY_LOGIN = "#login";
    public static String HISTORY_LOGOUT = "#logout";
    
    @UiField Hyperlink uploadDocumentLink;
    @UiField Hyperlink loginLink;
    @UiField Hyperlink logoutLink;
    @UiField HorizontalPanel menuPanel;
    
    Hyperlink emptyLink;
    
    private static PanelSuperiorUiBinder uiBinder = 
    	GWT.create(PanelSuperiorUiBinder.class);

    interface PanelSuperiorUiBinder extends UiBinder<Widget, TopPanel> { }

    public TopPanel() {
    	initWidget(uiBinder.createAndBindUi(this));
    	emptyLink = new Hyperlink();
		menuPanel.clear();
		menuPanel.add(uploadDocumentLink);
		menuPanel.add(loginLink);
		menuPanel.add(emptyLink);
    }

	public void setNavigationMode(String historyToken) {
		if (HISTORY_UPLOAD_DOCUMENT.equals(historyToken)) {
			menuPanel.clear();
			menuPanel.add(emptyLink);
			menuPanel.add(emptyLink);
			menuPanel.add(logoutLink);
		} else if (HISTORY_LOGIN.equals(historyToken)) {
			menuPanel.clear();
			menuPanel.add(emptyLink);
			menuPanel.add(emptyLink);
			menuPanel.add(logoutLink);
		} else if (HISTORY_LOGOUT.equals(historyToken)) {
			menuPanel.clear();
			menuPanel.add(uploadDocumentLink);
			menuPanel.add(loginLink);
			menuPanel.add(emptyLink);
		}
	}

}